#!/bin/sh

cd <%= node['gitlab'][@options[:rails_app]]['dir'] %>/working

exec 2>&1
<%= render("mount_point_check.erb") %>
exec chpst -e /opt/gitlab/etc/<%= @options[:rails_app] %>/env -P \
  -U <%= @options[:user] %> -u <%= @options[:user] %> \
  /opt/gitlab/embedded/bin/bundle exec sidekiq \
    -q post_receive \
    -q mailers \
    -q archive_repo \
    -q system_hook \
    -q project_web_hook \
    -q gitlab_shell \
    -q incoming_email \
    -q common \
    -q pages \
    -q elasticsearch \
    -q default \
    -e <%= node['gitlab'][@options[:rails_app]]['environment'] %> \
    -r /opt/gitlab/embedded/service/<%= @options[:rails_app] %> \
    -t <%= @options[:shutdown_timeout] %> \
    -c <%= @options[:concurrency] %>
